This patch fixes a number of vcpu related issues.
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 15 Nov 2005 16:28:05 +0000 (17:28 +0100)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 15 Nov 2005 16:28:05 +0000 (17:28 +0100)
1.  xm vcpu-list now shows info for all vcpus by using
    info['max_vcpu_id']+1 as end of the range to query
    vcpu_info.
2.  Add new vcpu fields, online_vcpus, max_vcpu_id to
    XendDomainInfo.sxpr()
3.  Remove filter_cpump() which isn't needed now that
    the per vcpu cpumap field is correct.
4.  Update xm/main.py to use online_vcpus as the number
    vcpus to display in list.

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xm/main.py

index 886d5c4f0f7f4db7f1bf2ac23a0922dd75d2f2b1..c634cb862310bbbd1ad3b0c3568b44d3103bd899 100644 (file)
@@ -438,8 +438,10 @@ class XendDomainInfo:
             defaultInfo('cpu',          lambda: None)
             defaultInfo('cpu_weight',   lambda: 1.0)
             defaultInfo('vcpus',        lambda: int(1))
+            defaultInfo('online_vcpus', lambda: self.info['vcpus'])
 
             self.info['vcpus'] = int(self.info['vcpus'])
+            defaultInfo('max_vcpu_id',  lambda: self.info['vcpus']-1)
 
             defaultInfo('vcpu_avail',   lambda: (1 << self.info['vcpus']) - 1)
 
@@ -927,6 +929,7 @@ class XendDomainInfo:
         if self.infoIsSet('cpu_time'):
             sxpr.append(['cpu_time', self.info['cpu_time']/1e9])
         sxpr.append(['vcpus', self.info['vcpus']])
+        sxpr.append(['online_vcpus', self.info['online_vcpus']])
             
         if self.infoIsSet('start_time'):
             up_time =  time.time() - self.info['start_time']
@@ -943,16 +946,13 @@ class XendDomainInfo:
 
     def getVCPUInfo(self):
         try:
-            def filter_cpumap(map, max):
-                return filter(lambda x: x >= 0, map[0:max])
-
             # We include the domain name and ID, to help xm.
             sxpr = ['domain',
                     ['domid',      self.domid],
                     ['name',       self.info['name']],
-                    ['vcpu_count', self.info['vcpus']]]
+                    ['vcpu_count', self.info['online_vcpus']]]
 
-            for i in range(0, self.info['vcpus']):
+            for i in range(0, self.info['max_vcpu_id']+1):
                 info = xc.vcpu_getinfo(self.domid, i)
 
                 sxpr.append(['vcpu',
@@ -962,8 +962,7 @@ class XendDomainInfo:
                              ['running',  info['running']],
                              ['cpu_time', info['cpu_time'] / 1e9],
                              ['cpu',      info['cpu']],
-                             ['cpumap',   filter_cpumap(info['cpumap'],
-                                                        self.info['vcpus'])]])
+                             ['cpumap',   info['cpumap']]])
 
             return sxpr
 
index ec4bf16d3a99e19e0b4877ca72751d4225cbd3f3..fc0521fe3fff8cb879b746170d3fef0c26214d10 100644 (file)
@@ -260,13 +260,13 @@ def parse_doms_info(info):
         return t(sxp.child_value(info, n, d))
     
     return {
-        'dom'      : get_info('domid',    int,   -1),
-        'name'     : get_info('name',     str,   '??'),
-        'mem'      : get_info('memory',   int,   0),
-        'vcpus'    : get_info('vcpus',    int,   0),
-        'state'    : get_info('state',    str,   '??'),
-        'cpu_time' : get_info('cpu_time', float, 0),
-        'ssidref'  : get_info('ssidref',  int,   0),
+        'dom'      : get_info('domid',        int,   -1),
+        'name'     : get_info('name',         str,   '??'),
+        'mem'      : get_info('memory',       int,   0),
+        'vcpus'    : get_info('online_vcpus', int,   0),
+        'state'    : get_info('state',        str,   '??'),
+        'cpu_time' : get_info('cpu_time',     float, 0),
+        'ssidref'  : get_info('ssidref',      int,   0),
         }